<?php

/**
 * Description of my
 * 
 * @author 叶风
 * Qq:    355007778
 * Email: ye.fn@163.com
 */

namespace c\msg;

class my extends \control
{
    var $table = 'msg';
    var $class = array('PU'=>'\c\auth\permission');
    var $dispLayout = 'user';
    
    function index_home()
    {
        $this->PU->login();
        $r = $this->db->get_page(array(), $this->table, '*', 'to_user='. \YF_f::$login_user_id, 'id DESC');
        $this->loadTemplate('msg/home', array('res'=>$r));
    }
    function index_del()
    {
        $this->PU->login();
        $id = $_GET['id'];
        $b = $this->db->del($this->table, 'id='. $id .'  AND to_user='. \YF_f::$login_user_id);
        ajax_json($b ? TRUE :\lang::g('Over'));
    }
    function newNum()
    {
        return $this->db->getOneField($this->table, 'count(*)', 'is_read=0 AND to_user='. \YF_f::$login_user_id);
    }
}
